package com.shengyo.model.service.impl;

import java.util.List;

import com.shengyo.model.bean.Mobile;
import com.shengyo.model.dao.IMobileDAO;
import com.shengyo.model.service.IMobileService;

public class MobileServiceImpl implements IMobileService{

	private IMobileDAO mobileDAO;
	
	public IMobileDAO getMobileDAO() {
		return mobileDAO;
	}

	public void setMobileDAO(IMobileDAO mobileDAO) {
		this.mobileDAO = mobileDAO;
	}

	public MobileServiceImpl() {
		super();
	}

	public void delete(int id) {
		Mobile mobile = this.findById(id);
		if(mobile != null)
			mobileDAO.delete(mobile);
	}

	
	@SuppressWarnings("unchecked")
	public List<Mobile> findAll() {
		return mobileDAO.findAll();
	}

	
	public Mobile findById(int id) {
		return (Mobile) mobileDAO.findById(id);
	}

	@Override
	public Mobile saveOrUpdate(Mobile mobile) {
		mobile = (Mobile) mobileDAO.save(mobile);
		return mobile;
	}

	public Mobile findByMobileUrl(String url){
		return mobileDAO.findByMobileUrl(url);
	}
}
